﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpVersion_2
{
    class StaticField
    {
        public static void TestResult()
        {
            Console.WriteLine("打印T=string测试结果");
            GenericCounter<string>.Increment();
            GenericCounter<string>.Increment();
            GenericCounter<string>.Display();

            Console.WriteLine("打印T=int测试结果");
            GenericCounter<int>.Display();
            GenericCounter<int>.Increment();
            GenericCounter<int>.Display();
        }
    }
    class GenericCounter<T>
    {
        private static int value;
        static GenericCounter()
        {
            Console.WriteLine("Initializing counter for {0}", typeof(T));
        }
        public static void Increment()
        {
            value++;
        }
        public static void Display()
        {
            Console.WriteLine("Counter for {0}: {1}", typeof(T), value);
        }
    }
}
